﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using EzDesk.Utility.Log;
using EzDesk.Utility.Web.Controllers;
using EzDesk.Clients.DesktopWeb.ClientTokenService;
using EzDesk.Utility.Web.ServiceReference;

namespace EzDesk.Clients.DesktopWeb.Controllers
{
    public class HomeController : EzDeskController
    {
        private IClientTokenService ClientTokenService
        {
            get { return ServiceReferenceFactory<IClientTokenService, ClientTokenServiceClient>.GetService(); }
        }

        public ActionResult TokenLogon(string ez_auth_token)
        {
            try
            {
                Guid userId = ClientTokenService.GetUserIdByToken(ez_auth_token);
                FormsAuthentication.RedirectFromLoginPage(userId.ToString(), false);
            }
            catch (Exception ex)
            {
                LogEx.ERROR("[Core - Home]", "Token验证失败，可能是非法操作！！", ex);
            }
            return null;
        }

        [HttpGet]
        public ActionResult Error()
        {
            return View();
        }

        [HttpGet]
        public ActionResult HitPage()
        {
            return Json("1");
        }


        //
        // GET: /Home/
        [Authorize]
        public ActionResult Index()
        {
            return View();
        }


        //
        // GET: /Home/
        [Authorize]
        public ActionResult RequestBridge()
        {
            return View();
        }

    }
}
